<template>
    <PageView>
        <a-card title="列表">
            <a-row :gutter="10" class="inputGroup">
                <a-col :xs="12" :md="6" :lg="6" :xl="4">
                    <a-input v-model="searchData.username" placeholder="管理员账号" @keyup.enter="getListTwo"/>
                </a-col>
                <a-col :xs="12" :md="6" :lg="6" :xl="4">
                    <a-input v-model="searchData.uid" placeholder="充值账号" @keyup.enter="getListTwo"/>
                </a-col>
                <a-col :xs="12" :md="6" :lg="6" :xl="4">
                    <a-select allowClear v-model="searchData.type" style="width:100%" placeholder="钱包类型"
                              @change="getListTwo">
                        <a-select-option value="1">排单积分</a-select-option>
                        <a-select-option value="2">收益积分</a-select-option>
                        <a-select-option value="3">股东积分</a-select-option>
                    </a-select>
                </a-col>
                <a-col :xs="12" :md="6" :lg="6" :xl="4">
                    <a-select allowClear v-model="searchData.status" style="width:100%" placeholder="加减"
                              @change="getListTwo">
                        <a-select-option value="1">增加</a-select-option>
                        <a-select-option value="2">减少</a-select-option>
                    </a-select>
                </a-col>
                <a-col :xs="12" :md="6" :lg="6" :xl="4">
                    <a-button-group>
                        <a-button type="primary" :loading="loading" @click="getListTwo">确定筛选</a-button>
                    </a-button-group>
                </a-col>
            </a-row>
            <a-table
                :loading="loading"
                :columns="columns"
                :dataSource="data"
                :pagination="{total,pageSize,showSizeChanger,current}"
                @change="changePagination"
                bordered :scroll="{x:true}">
            </a-table>
        </a-card>
    </PageView>
</template>

<script type="text/jsx">
    import Member from '../../api/Member'
    export default {
        name: 'recordRecharge',
        data () {
            return {
                loading: true,
                columns: [
                    {
                        title: '管理员账号',
                        dataIndex: 'username',
                        customRender: (v) => <a>{v}</a>
                    },
                    {
                        title: '充值账号',
                        dataIndex: 'uid',
                    },
                    {
                        title: '钱包类型',
                        dataIndex: 'type',
                        customRender: (v) => {
                            return{
                                1: "排单积分",
                                2: "收益积分",
                                3: "股东积分",
                            }[v]
                        }
                    },
                    {
                        title: '加减',
                        dataIndex: 'status',
                        customRender: (v) => {
                            let status = {
                                1: { name: '增加', color: 'success' },
                                2: { name: '减少', color: 'error' }
                            }
                            return <a-badge status={status[v].color} text={status[v].name}/>
                        }
                    },
                    {
                        title: '数量',
                        dataIndex: 'money',
                    },
                    {
                        title: '充值时间',
                        dataIndex: 'add_time',
                        customRender: (v) => this.timeOne(v)
                    },
                ],
                data: [],
                total: 0,
                pageSize: 10,
                current: 1,
                showSizeChanger: true,
                searchData: {
                    username: '',
                    uid:"",
                    status:undefined,
                    type:undefined,
                },
                time: [],
            }
        },
        activated () {
            this.getList()
        },
        methods: {
            getListTwo () {
                this.current = 1
                this.getList()
            },
            getList () {
                this.loading = true
                Member.getRechargeLog({
                    page: this.current,
                    num: this.pageSize,
                    ...this.searchData,
                }).then(res => {
                    this.data = res.data.map((value, key) => {
                        return { ...value, key }
                    })
                    this.loading = false
                    this.total = parseInt(res.count)
                })
            },
            changePagination (pagination) {
                Object.keys(pagination).forEach(val => {
                    this[val] = pagination[val]
                })
                this.getList()
            },
        }
    }
</script>

<style scoped lang="less">
    .inputGroup {
        > div {
            margin-bottom: 20px;
        }
    }
</style>